using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class pages_register : System.Web.UI.Page
{
    CardTypeDAO daoCardType = new CardTypeDAO();
    AccountDAO daoAccount = new AccountDAO();
    protected void Page_Load(object sender, EventArgs e)
    {
        IList<CardType> types = daoCardType.GetAll();
        cmbCardType.Items.Clear();
        foreach (CardType type in types)
        {
            ListItem item = new ListItem(type.TypeName,type.CardTypeID.ToString());
            cmbCardType.Items.Add(item);
        }
    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        Page.Validate("reg");
        if (IsValid)
        {
            MemberInfo member = new MemberInfo();
            member.Username = txtUsername.Text;
            member.Password = txtPassword.Text;
            member.Level = 1;
            member.FirstName = txtFirstname.Text;
            member.LastName = txtLastname.Text;
            member.Email = txtEmail.Text;
            member.Phone = txtPhone.Text;
            member.Address = txtAddress.Text;
            member.Card.Type.CardTypeID = int.Parse(cmbCardType.SelectedItem.Value);
            member.Card.CardNumber = txtCartNumber.Text;
            if (daoAccount.Insert(member) > 0)
            {
                Response.Write("Successed");
            }
        }
       
    }
}
